/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef __LIB3D_HARD_MACX_VERTEX_BUFFER_H__
#define __LIB3D_HARD_MACX_VERTEX_BUFFER_H__

#include <lib3d/hard/VertexBuffer.h>
#include <win32/win32.h>
#include <gl/GL.h>

namespace liba
{
namespace lib3d
{
namespace hard
{
namespace macx
{
class Hardware;

class VertexBuffer : public hard::VertexBuffer
{
	GLuint vertex_buffer;
	int vertices_count;
	bool valid_flag;
	int stride;
	bool dynamic;

	int normals_stride;
	int colors_stride;
	int uvs_stride;

public:
	explicit VertexBuffer(Hardware * hardware, bool dynamic );
	virtual ~VertexBuffer();
	virtual bool is_valid()const;
	virtual bool update(
		const SimpleArray<float> & positions,
		const SimpleArray<float> & normals,
		const SimpleArray<float> & u_tangents,
		const SimpleArray<float> & v_tangents,
		const SimpleArray<float> & uv0,
		const SimpleArray<float> & uv1,
		const SimpleArray<float> & weights0,
		const SimpleArray<float> & weights1,
		const SimpleArray<float> & weights2,
		const SimpleArray<int> & indices0,
		const SimpleArray<int> & indices1,
		const SimpleArray<int> & indices2,
		const SimpleArray<int> & indices3
		);
	virtual bool update(
		const SimpleArray<float> & positions,
		const SimpleArray<float> & normals,
		const SimpleArray<float> & colors,
		const SimpleArray<float> & uv0,
		const SimpleArray<float> & uv1
		);
	virtual bool render( int vertex_pos, int primitive_count );
	virtual bool render( hard::IndexBuffer * ib, int index_pos, int primitive_count, int vertex_pos, int vertex_count );
	virtual bool render( hard::VertexBuffer * vb2, int vertex_pos, int primitive_count );
	virtual bool render( hard::VertexBuffer * vb2, hard::IndexBuffer * ib, int index_pos, int primitive_count, int vertex_pos, int vertex_count );
};

} // namespace macx
} // namespace hard
} // namespace lib3d
} // namespace liba
using namespace liba;

#endif //__LIB3D_HARD_MACX_VERTEX_BUFFER_H__

